﻿using exMath.Common;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace exMath.Test
{
    
    
    /// <summary>
    ///This is a test class for StaticDataFunctionTest and is intended
    ///to contain all StaticDataFunctionTest Unit Tests
    ///</summary>
    [TestClass()]
    public class StaticDataFunctionTest
    {


        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        ///A test for GeneratedFunction
        ///</summary>
        [TestMethod()]
        public void GeneratedFunctionTest()
        {
            //test a simple slope between (0,0) and (1,1).
            double[] DomainValues = { 0.0, 1.0 };
            double[] RangeValues = { 0.0, 1.0 };

            StaticDataFunction df = new StaticDataFunction(DomainValues, RangeValues);
            double result = df.GeneratedFunction(0.5);
            double result2 = df.GeneratedFunction(1.0);

            Assert.AreEqual(0.5, result);
            Assert.AreEqual(1.0, result2);

            //also test the downwards slope
            double[] DomainValues2 =    { 0.0, 0.5, 1.0 };
            double[] RangeValues2 =     { 0.0, 2.0, 1.5 };

            StaticDataFunction df2 = new StaticDataFunction(DomainValues2, RangeValues2);
            double result3 = df2.GeneratedFunction(0.25);
            double result4 = df2.GeneratedFunction(0.75);

            Assert.AreEqual(1.0, result3);
            Assert.AreEqual(1.75, result4);
            
        }
    }
}
